#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
using namespace std;
class Solution {
public:
    int singleNumber(vector<int>& nums) {
        int ans = 0;
        for (size_t i = 0; i < 32; i++)
        {
            int total = 0;
            for (auto num : nums)
            {
                total += ((num >> i) & 1);
            }
            if (total % 3)
            {
                ans |= (1 << i);
            }
        }
        return ans;
    }
};